import java.util.Scanner;

public class Shuixianshu {
    public static void Shuixianshu(int n){
        while(n != 0){
            int d = n % 10;
            System.out.println(d);
            n = n / 10;
        }
    }
    public static void main(String[] args) {
        Shuixianshu(123851);
    }
}
